<extend name="Shops:layout" />
<block name="content">
<style type="text/css">
#preview{border:1px solid #cccccc; background:#CCC;color:#fff; padding:5px; display:none; position:absolute;}
</style>
<script>
$(document).ready(function(){
    $('.imgPreview').imagePreview();
    <notempty name='shopCatId1'>
    getShopCatListForGoods('{$shopCatId1}','{$shopCatId2}');
    </notempty>
});
</script>
    <div class="wst-body"> 
       <div class='wst-page-header'>卖家中心 > 商品管理</div>
       <div class='wst-page-content'>
        <div class='wst-tbar-query'>
        店铺分类：<select id='shopCatId1' autocomplete="off" onchange='javascript:getShopCatListForGoods(this.value,"{$object['shopCatId2']}")'>
	         <option value='0'>请选择</option>
	         <volist name="shopCatsList" id="vo">
	         <option value='{$vo['catId']}' <if condition="$shopCatId1 == $vo['catId'] ">selected</if>>{$vo['catName']}</option>
	         </volist>
	     </select>
	     <select id='shopCatId2' autocomplete="off">
	         <option value='0'>请选择</option>
	     </select>
        商品：<input type='text' id='goodsName' value='{$goodsName}'/>
      <button class='wst-btn-query' onclick='javascript:queryOnSale()'>查询</button>
        </div>
  
        <table class='wst-list'>
           <thead>
             <tr>
               <th>ID</th>
               <th>商品名称</th>
               <th width="80">已参与/总需</th>
               <th width="80">单价/元</th>
               <th width="110">期数/最大期数</th>
               <th width="90">人气商品</th>
			   <th width="90">揭晓状态</th>
               <th width='180'>操作</th>
             </tr>
           </thead>
           <tbody>
            <volist name="list" id="vo" key='i'>
             <tr>
              <td>{$vo.id}</td>
               <td>
               {$vo['title']}
               </td>
               <td>
               		<font color="#ff600">{$vo['canyurenshu']}</font> / {$vo['zongrenshu']}
               </td>
			   <td>{$vo['yunjiage']}</td>
			   <td>{$vo['qishu']} / {$vo['maxqishu']}</td>
			   <td>
			   	<if condition="$vo['renqi']">
			   		<font color="#ff600">人气</font>
				<else/>
					<a href="javascript:;" class="yunsetrenqi" item="{$vo['id']}">设为人气</a>
				</if>
			   </td>
			   <td>
			   	<if condition="$vo['q_end_time']">
			   		<font color="#ff600">已揭晓</font>
				<else/>
					<a href="javascript:;">未揭晓</a>
				</if>
			   </td>
               <td>
				<a href="{:U('yunedit',array('gid' => $vo['id']))}">[修改]</a>
				<a href="{:U('yundelete',array('gid' => $vo['id']))}">[删除]</a>
               <a href="{:U('yundesc',array('gid' => $vo['id']))}">[购买详情]</a>
			   </td>
             </tr>
             </volist>
             <tfoot>
             <tr>
                <td colspan='12'>
                <div class="wst-page" style="float:right;padding-bottom:10px;">
						<div id="wst-page-items"></div>
				</div>
                <script>
			   
			    $(document).ready(function(){
				
				$('.yunsetrenqi').click(function(){
					var goodsId = $(this).attr('item');
					if(!goodsId) return;
					$.post(Think.U('Home/Goods/yunsetrenqi'),{gid:goodsId},function(data,textStatus){
						var json = WST.toJson(data);
						alert(json);
					});
				});
					

					
					<if condition="$pageTotal gt 1">
					laypage({
					    cont: 'wst-page-items',
					    pages: {$pageTotal}, //总页数
					    skip: true, //是否开启跳页
					    skin: '#e23e3d',
					    groups: 3, //连续显示分页数
					    curr: function(){ //通过url获取当前页，也可以同上（pages）方式获取
					        var page = location.search.match(/p=(\d+)/);
					        return page ? page[1] : 1;
					    }(), 
					    jump: function(e, first){ //触发分页后的回调
					        if(!first){ //一定要加此判断，否则初始时会无限刷新
					        	var nuewurl = WST.splitURL("p");
					        	var ulist = nuewurl.split("?");
					        	if(ulist.length>1){
					        		location.href = nuewurl+'&p='+e.curr;
					        	}else{
					        		location.href = '?p='+e.curr;
					        	}
					            
					        }
					    }
					});
					
					</if>
					
			    });
				
				</script>
                </td>
             </tr>
             </tfoot>
           </tbody>
        </table>

        </div>
    </div>
</block> 